package recursion;

/**
 * @Author Stringzhua
 * @Date 2024/2/28 14:42
 * description:
 */
public class recursion01 {
    public static void main(String[] args) {
        T t1 = new T();
        t1.test(4);
        //输出什么
        int res=t1.factorial(5);
        System.out.println("res = " + res);
    }
}

class T {
    public void test(int n) {
        if (n > 2) {
            test(n - 1);
        }
        System.out.println("n = " + n);
//        else{
////            System.out.println("n = " + n);//n=2
//        }
    }
//factorial 阶乘
    public int factorial(int n) {
        if (n == 1) {
            return 1;
        } else {
            return factorial(n - 1) * n;
        }
    }
}
